package com.only.webServer.servlet;

import com.only.webServer.DispatcherServlet;
import com.only.webServer.request.HttpRequest;
import com.only.webServer.response.HttpResponse;
import com.only.webServer.response.HttpStatus;

public class ErrorServlet extends Servlet{
    @Override
    public void doGet(HttpRequest request, HttpResponse response) {
        if ("/404".equals(request.getPathMapping())) {
            response.setHttpStatus(HttpStatus.NOT_FOUND);
            request.setPathMapping("/error/404/index.html");
        }else if ("/500".equals(request.getPathMapping())){
            response.setHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR);
            request.setPathMapping("/error/500/index.html");
        }
        DispatcherServlet.dispense(request, response);
    }

    @Override
    public void doPost(HttpRequest request, HttpResponse response) {

    }
}
